package com.linkage.jz.bankruptcy.widget;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.linkage.jz.bankruptcy.R;

public class PublicCompareNoticeDialog extends Dialog {

	/**
	 * 上下文对象 *
	 */
	Activity context;

	private Button btn_save_notice,btn_chancel_notice;

	private LinearLayout ll_notice,ll_bt_z,ll_close;
	public TextView tv_content_cur,tv_content_old;


	private View.OnClickListener mClickListener;

	/*
	1.标题  内容 确定 取消 关闭
	2.标题  确定 取消 关闭
	3.标题  确定 关闭
	4.标题  内容 关闭
		5.标题  内容 确定 关闭
	 */
	private int mType = -1;
	private String mTitle;
	private String mContentCur;
	private String mContentOld;


	public PublicCompareNoticeDialog(Activity context) {
		super(context);
		this.context = context;
	}

	public PublicCompareNoticeDialog(Activity context, View.OnClickListener clickListener,
                                     String contentCur, String contentOld) {
		super(context);
		this.context = context;
		mContentCur = contentCur;
		mContentOld = contentOld;
		this.mClickListener = clickListener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 指定布局

		this.setContentView(R.layout.public_compare_notice_dialog);




		tv_content_cur =  findViewById(R.id.tv_content_cur);

		tv_content_old =  findViewById(R.id.tv_content_old);

		ll_close = findViewById(R.id.ll_close);


		ll_close.setOnClickListener(mClickListener);


		tv_content_cur.setText(mContentCur);
		tv_content_old.setText(mContentOld);

		/*
		 * 获取圣诞框的窗口对象及参数对象以修改对话框的布局设置, 可以直接调用getWindow(),表示获得这个Activity的Window
		 * 对象,这样这可以以同样的方式改变这个Activity的属性.
		 */
		Window dialogWindow = this.getWindow();

		WindowManager m = context.getWindowManager();
		Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
		WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
		// p.height = (int) (d.getHeight() * 0.6); // 高度设置为屏幕的0.6
		p.width = (int) (d.getWidth() * 0.9); // 宽度设置为屏幕的0.8
		dialogWindow.setAttributes(p);

		// 根据id在布局中找到控件对象
//		btn_save_u = (Button) findViewById(R.id.btn_save_u);
//
//		btn_chancel_u = (Button)findViewById(R.id.btn_chancel_u);
//		// 为按钮绑定点击事件监听器
//		btn_save_u.setOnClickListener(mClickListener);
//		btn_chancel_u.setOnClickListener(mClickListener);

		this.setCancelable(true);
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		if(event.getKeyCode() == KeyEvent.KEYCODE_BACK ) {
			//do something.
			if(isShowing())
			{
				return  false;
			}else{
				return  true;
			}

		}else {
			return super.dispatchKeyEvent(event);
		}
	}

}


